package com.book.controller;

import com.book.dto.BookClassesPage;
import com.book.service.BookClassesService;
import com.book.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * @author yicheng
 */
@RestController
@RequestMapping("/classes")
public class BookClassesController {
    @Autowired
    private BookClassesService bookClassesService;

    @PostMapping("/addBookClasses")
    public ResponseResult addBookClasses(@RequestParam int bookId, @RequestBody List<Integer> classId){
        return bookClassesService.addBookClasses(bookId,classId);
    }

    /**
     * 根据bookId获取bookclasses信息
     * @param bookClassesPage
     * @return
     */
    @PostMapping("/getBookClasses")
    public ResponseResult getBookClasses(@RequestBody BookClassesPage bookClassesPage){
        return bookClassesService.getBookClasses(bookClassesPage);
    }


    @GetMapping("/deleteClassesById")
    public ResponseResult deleteClassesById(@RequestParam int id){
        return bookClassesService.deleteClassesById(id);
    }
}
